package nc.bs.dao;

import java.lang.reflect.Array;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.IVOPersistence;
import nc.jdbc.framework.DataSourceCenter;
import nc.jdbc.framework.JdbcSession;
import nc.jdbc.framework.PersistenceManager;
import nc.jdbc.framework.SQLParameter;
import nc.jdbc.framework.exception.DbException;
import nc.jdbc.framework.mapping.IMappingMeta;
import nc.jdbc.framework.mapping.MappingMeta;
import nc.jdbc.framework.processor.BaseProcessor;
import nc.jdbc.framework.processor.BeanMappingListProcessor;
import nc.jdbc.framework.processor.ResultSetProcessor;
import nc.vo.pub.SqlSupportVO;
import nc.vo.pub.SuperVO;
import nc.vo.pub.UpdateResultVO;

public final class BaseDAO2
 // implements IVOPersistence, IUAPQueryBS
{
  private String b = null;

  int a = 100000;

  public BaseDAO2()
  {
  }

  public BaseDAO2(String paramString)
  {
    this.b = paramString;
  }





  public final String insertVOWithPK(SuperVO paramSuperVO)
    throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    String str = null;
    try
    {
      str = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .insertWithPK(paramSuperVO);
    }
    
    catch (DbException localDbException2)
    {
      DbException localDbException1;
        throw new DAOException(((DbException)localDbException2).getMessage());
      //throw new DAOException(((DbException)localDbException1).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
    return str;
  }

  public final String insertVO(SuperVO paramSuperVO)
    throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    String str = null;
    try
    {
      str = (localPersistenceManager = PersistenceManager.getInstance(this.b)).insert(paramSuperVO);
    }
    catch (DbException localDbException2)
    {
      DbException localDbException1;
      //throw new DAOException(localDbException1.getMessage());
      throw new DAOException(((DbException)localDbException2).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
    return str;
  }

  public final String[] insertVOArrayWithPK(SuperVO[] paramArrayOfSuperVO)
    throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    String[] arrayOfString = null;
    try
    {
      arrayOfString = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .insertWithPK(paramArrayOfSuperVO);
    }
    catch (DbException localDbException2)
    {
      DbException localDbException1;
      //throw new DAOException(localDbException1.getMessage());
      throw new DAOException(((DbException)localDbException2).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
    return arrayOfString;
  }

  public final String[] insertVOArray(SuperVO[] paramArrayOfSuperVO)
    throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    String[] arrayOfString = null;
    try
    {
      arrayOfString = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .insert(paramArrayOfSuperVO);
    }
    catch (DbException localDbException2)
    {
      DbException localDbException1;
      //throw new DAOException(localDbException1.getMessage());
      throw new DAOException(((DbException)localDbException2).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
    return arrayOfString;
  }

  public final String[] insertVOList(List paramList)
    throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    String[] arrayOfString = null;
    try
    {
      arrayOfString = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .insert(paramList);
    }
    catch (DbException localDbException2)
    {
      DbException localDbException1;
      //throw new DAOException(localDbException1.getMessage());
      throw new DAOException(((DbException)localDbException2).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
    return arrayOfString;
  }

  public final String insertObjectWithPK(Object paramObject, IMappingMeta paramIMappingMeta) throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    Object localObject1;
    try
    {
      localObject1 = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .insertObjectWithPK(paramObject, paramIMappingMeta);

      return localObject1.toString();
    }
    catch (DbException localDbException)
    {
      throw new DAOException(((DbException)localDbException).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
  }

  public final String insertObject(Object paramObject, IMappingMeta paramIMappingMeta) throws DAOException
  {
    PersistenceManager localPersistenceManager = null;
    Object localObject1;
    try
    {
      localObject1 = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .insertObject(paramObject, paramIMappingMeta);

      return localObject1.toString();
    }
    catch (DbException localDbException)
    {
      throw new DAOException(((DbException)localDbException).getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
  }

 




  public final int getDBType()
  {
    return DataSourceCenter.getInstance().getDatabaseType(this.b);
  }

  protected final String getTableName(int paramInt, String paramString)
  {
    String str = null;
    switch (paramInt)
    {
    case 2:
    case 0:
    case 1:
      str = paramString.toUpperCase();
    }

    return str;
  }

  public final boolean isTableExisted(String paramString)
    throws DAOException
  {
    if (paramString == null)
      throw new NullPointerException("TableName is null!");
    PersistenceManager localPersistenceManager = null;
    try
    {
      int i = (
        localPersistenceManager = PersistenceManager.getInstance(this.b))
        .getDBType();

      DatabaseMetaData localDatabaseMetaData = localPersistenceManager.getMetaData();
      ResultSet localResultSet;
      return ((
        localResultSet = localDatabaseMetaData.getTables(localPersistenceManager.getCatalog(), localPersistenceManager.getSchema(), getTableName(i, paramString), new String[] { "TABLE" }))
        .next());
    }
    catch (Exception localException2)
    {
      Exception localException1;
      throw new DAOException(localException2.getMessage());
    } finally {
      if (localPersistenceManager != null)
        localPersistenceManager.release();
    }
  }

  public final void deleteVOArray(SuperVO[] paramArrayOfSuperVO)
  throws DAOException
{
  PersistenceManager localPersistenceManager = null;
  try {
    (
      localPersistenceManager = PersistenceManager.getInstance(this.b))
      .delete(paramArrayOfSuperVO);

    return;
  }
  catch (DbException localDbException2)
  {
    DbException localDbException1;
    throw new DAOException(localDbException2.getMessage());
  } finally {
    if (localPersistenceManager != null)
      localPersistenceManager.release();
  }
}
  
  public final int getMaxRows() {
    return this.a;
  }

  public final void setMaxRows(int paramInt) {
    this.a = paramInt;
  }
}